﻿// TestSTL01.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。


#include <iostream>
#include <fstream>
#include <sstream>
#include <tuple>
using namespace std;
class Person {
private:
	string person;
public:
	Person() = default;
	Person(string str):person(str){};

	friend std::ostream& operator<<(std::ostream& os, const Person& p) {
    	os << p.person;
    	return os;
	}
};

template< int IDX, int MAX, typename... Args>
struct PRINT_TUPLE
{
	/* data */
	static void print(ostream& os, const tuple<Args...>& t) {
		os<<get<IDX>(t)<<(IDX+1 == MAX ? "" : ",");
		PRINT_TUPLE<IDX+1, MAX, Args...>::print(os, t);
	}
};

//特化的类模板（IDX == MAX）
template<int MAX, typename... Args>
struct PRINT_TUPLE<MAX, MAX, Args...>
{
	/* data */
	static void print(ostream& os, const tuple<Args...>& t) {
	}
};


template<typename... Args>
ostream& operator<<(ostream& os, const tuple<Args...>&t) {
	os<<"[";
	PRINT_TUPLE<0, sizeof...(Args), Args...>::print(os, t);
	return os<<"]";
}

int main()
{
	Person p = Person("I am boy");
	tuple<int, string, Person> tuple = {1, "2.3", p};
	cout<<tuple<<endl;
}
